package com.example.elasticsearch.controller;

import com.example.elasticsearch.service.SearchService;
import com.example.elasticsearch.vo.SearchParam;
import com.example.elasticsearch.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;

/**
 * @author guanglin.ma
 * @date 2023-12-27 11:51
 */
@Controller
//@RestController
public class SearchController {

    @Autowired
    private SearchService searchService;

    @RequestMapping("/search.html")
    public String search(SearchParam searchParam, Model model) throws IOException {
        SearchResult result = searchService.search(searchParam);
        model.addAttribute("result",result);
        return "index";
    }

    @RequestMapping("/list.html")
    public String catelogList(String catalog3Id, Model model) {
        return "index";
    }
}
